<template>
    <el-dialog title="" visible :show-close="false" class="wrap" size="tiny">
        <i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		<div class="bt">结转</div>
        <el-form label-width="100px" class="form">
            <el-form-item label="学生名称">
                <el-input v-model="form.zwm" :readonly="true" class="select-block"></el-input>
            </el-form-item>
            <!--<el-form-item label="未上课时">
                <el-input v-model="params.row.syks" :readonly="true" class="select-block"></el-input>
            </el-form-item>-->
            <el-form-item label="基础价格">
                <el-input v-model="params.row.jcjg" :readonly="true" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="最高结转金额">
                <el-input v-model="params.row.tfje" :readonly="true"  class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="结转课时">
                <el-input v-model="form.jzks" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="实际结转金额">
                <el-input v-model="tfje"  class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="结转原因">
 				<el-input v-model="form.tfyy" type="textarea" :rows="4" placeholder="请输入备注信息" class="select-block"></el-input>
 			</el-form-item>
        </el-form>
        <el-button type="primary" class="submit" @click="submit">结转</el-button>
    </el-dialog>
</template>

<script type="text/javascript">

    import qs from 'qs'
    export default {
        props: ['params'],
        data () {
            return {
                form: {
                    zwm: '',
                    jzks:'',
//                  tfje:'',
					tfyy:'',
                    id:''
                },
            }
        },
        created () {
            // console.log(this.params)
            this.form.zwm=this.params.row.zwm;//从list获取中文名
            this.form.id=this.params.row.id;//从list获取课时id
            this.form.xsid=this.params.row.xsid;//从list获取学生id
        },
        methods: {
            submit () {
                this.$store.state.loading = true;
//              if (!this.form.chinese) {
//                  this.$message.warning('请填写老师中文名');
//                  return;
//              }else if(!this.form.type){
//                  this.$message.warning('请选择老师类型');
//                  return;
//              }else if(!this.form.school){
//                  this.$message.warning('请选择学校');
//                  return;
//              }
	             var logininfo = JSON.parse(localStorage.logininfo);
               var params3 = qs.stringify({
                  xsid: this.form.xsid,
                  xsksid:this.form.id,
                  tfje:this.tfje,
                  jzks:this.form.jzks,
                  tfyy:this.form.tfyy+'',
                  xxid: logininfo.xxid,
                  yhid: logininfo.id
    						});
                this.axios.post( this.$store.state.api + 'xstf/addjz', params3)
                .then( res => {
                        this.$emit('close',{type:'edit',cancel:false});
                        this.$store.state.loading = false;
                }).catch( res => {
                    this.$message.danger("服务器异常!")
                    this.$store.state.loading = false;
                })
            },
            getTime (val) {
                this.form.time = val;
            },
            cancel () {
                this.$emit('close',{type:'edit',cancel:true})
            },
        },
         computed: {
//       	tfje(){
//          let number = this.params.row.syks * this.params.row.jcjg;
//          if (number<=0) {
//            return 0.00
//          }
//          return number
//        },
          tfje(){
            let number = this.form.jzks * this.params.row.jcjg ;
            if (number<=0) {
              return 0.00
            }else if(number<=this.params.row.tfje){
            	return number
            }else{
            	this.$message.warning('输入课时有误')
            }
//          return number
          },
         }
    }
</script>

<style lang="less" scoped>
    .wrap {
        text-align: center;
    }
   .bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
    .form {
        text-align: left;
        margin-top: 20px;

    }
    .input {
             display: inline-block;
         }
    .select-block {
        display: block;
        width: 85%;
    }
    .submit {
        width: 120px;
    }
</style>
